/**
 * 
 */
package us.gaaoc.framework.webapp.backingbeans.profile;

import javax.faces.context.FacesContext;

import us.gaaoc.framework.model.Person;
import us.gaaoc.framework.webapp.backingbeans.BaseBackingBean;

/**
 * @author Sukhada
 * May 31, 2006
 * GAJE_BibbCounty_1.0
 */
public class EditUser extends BaseBackingBean {

	/**
	 * Default Serial Version UID
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Properties
	 */	
	private String firstName;
	private String lastName;

	/**
	 * Constructor
	 *
	 */
	public EditUser() {
	}

	/**
	 * @return Returns the firstName.
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * @param firstName The firstName to set.
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * @return Returns the lastName.
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * @param lastName The lastName to set.
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * This method edits the user's firstName, lastName
	 * @return String
	 */
	public String editUser(){
		FacesContext fc= this.getFacesContext();
		Person newPerson = (Person)fc.getExternalContext().getSessionMap().get("person");
		newPerson.setCanEdit(false);
		fc.getExternalContext().getSessionMap().put("person", newPerson);
		//newPerson.setFirstName(getFirstName());
    	//newPerson.setLastName(getLastName());
    	this.getModelFacade().getSession().update(newPerson);

    	//this.getModelFacade().makePersistent(newPerson);
    	
		return "viewProfile";
	}
}
